var utils = require('../../../utils/util.js')
var c = require('../../../utils/config.js')
Page({

  /**
   * 页面的初始数据
   */
  data: {
    childlist: [],
    page: 1,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    var token = wx.getStorageSync("userinfo").wap_token;
    var data = {
      url: "/zfshop/userext/myRelationUser",
      token: token,
      page: that.data.page,
      limit: 10
    };
    utils.request(data).then(function (res) {
      if (res.code == 0) {
        var data = res.data;

        if (data.length > 0) {
          that.setData({
            page: that.data.page + 1
          });
        }
        that.setData({
          childlist: that.data.childlist.concat(data)
        });
      } else {

      }
      wx.stopPullDownRefresh();
    });
  },

  ///下拉刷新
  onPullDownRefresh: function () {
    this.setData({
      childlist: [],
      page: 1,
    });
    this.onLoad();
  },
  //上拉加载
  onReachBottom: function () {
    this.onLoad();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})